import DataShow from "@/pages/Data"
import Layout from "@/pages/Layout"
import Login from "@/pages/Login"
import User from "@/pages/User";
import IncAndExp from '@/pages/IncAndExp';
import Budget from '@/pages/IncAndExp/budget'
// import DayPlan from "@/pages/Plan/dayPlan";
import PlanType from "@/pages/Plan/planType";
import Detail from "@/pages/IncAndExp/detail/index";
import { AuthRoute } from '@/components/AuthRoute'
import { history, HistoryRouter } from "@/utils/history"
import IncAndExpType from '@/pages/IncAndExp/type';
import IncAndExpChart from '@/pages/IncAndExp/chart';
import { Navigate } from "react-router-dom"
import React, { lazy } from "react";

const DayPlan = lazy(() => import('@/pages/Plan/dayPlan'))

// 懒加载
const withLoadingComponent = (comp: JSX.Element) => (
    <React.Suspense fallback={<div>loading...</div>}>
        {comp}
    </React.Suspense>
)


const routes = [
    {
        path: '/',
        element: <Navigate to='/dataShow' />,  //跳转
    },
    {
        path: '/login',
        element: <Login />
    },
    {
        path: '/dataShow',
        element: <DataShow />
    },
    {
        path: '/dayPlan',
        element: withLoadingComponent(<DayPlan />)
    },
    {
        path: '/planType',
        element: <PlanType />
    },
    {
        path: '/incAndExp',
        element: <IncAndExp />
    },
    {
        path: '/incAndExpType',
        element: <IncAndExpType />
    },
    {
        path: '/incAndExpChart',
        element: <IncAndExpChart />
    },
    {
        path: '/budget',
        element: <Budget />
    },
    {
        path: '/user',
        element: <User />
    },
    //没有找到路由的情况
    {
        path: '*',
        element: <Navigate to='/dataShow' />,  //重定向
    }
]

export default routes